package com.ctl.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctl.dto.CategoryDTO;
import com.ctl.entity.Category;
import com.ctl.service.CategoryService;
import com.ctl.mapper.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* @author stars
* @description 针对表【category(分类)】的数据库操作Service实现
* @createDate 2023-02-21 19:53:10
*/
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category>

    implements CategoryService{
    @Autowired
    private CategoryMapper mapper;
    @Override
    public List<CategoryDTO> getByCategorys() {
        return mapper.getByCategorys();
    }

    @Override
    @Transactional
    public Map<String,Object> updateByCategoryId(Category category) {
        mapper.updateByCategoryId(category);
        Map<String, Object> map = new HashMap<>();
        map.put("id",category.getId());
        map.put("name",category.getName());
        map.put("parent_id",category.getParentId());
        return map;
    }
}




